package main

import "fmt"

func main() {
	fmt.Println(majorityElement([]int{3, 2, 3}))
}

func majorityElement(nums []int) int {
	numsMap := make(map[int]int)
	for _, num := range nums {
		numsMap[num]++
	}
	maxCount := 0
	maxItem := 0
	for k, v := range numsMap {
		if maxCount < v {
			maxItem = k
			maxCount = v
		}
	}
	return maxItem
}
